import request from '@/utils/request'

const act_dsn_form_tableApi = {
  queryListByFormId: '/act_dsn_form_table/queryListByFormId',
  batchSave: '/act_dsn_form_table/batchSave',
  formRemoveById: '/act_dsn_form_table/formRemoveById'
}

/**
 * 通过formid查询表信息
 * @param {*} id
 */
export function formRemoveById(table, primarykey) {
  if (!table) {
    console.error('请输入表名称')
    return
  } 
  if (!primarykey) {
    console.error('请输入表主键')
    return
  }
  return request({
    url: act_dsn_form_tableApi.formRemoveById,
    method: 'post',
    params: {
      table,
      primarykey
    }
  })
}

/**
 * 通过formid查询表信息
 * @param {*} id
 */
export function queryListByFormId(params) {
  return request({
    url: act_dsn_form_tableApi.queryListByFormId,
    method: 'post',
    params: params
  })
}
/**
 * 批量保存
 * @param {*} id
 */
export function batchSave(data, layout) {
  return request({
    url: act_dsn_form_tableApi.batchSave,
    method: 'post',
    data: {
      tables: data,
      layout: layout
    }
  })
}